﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SmartSpace.Core;
using System.Web.Security;

namespace SmartSpace.UI.Silverlight.Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.TextBox1.Focus();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(TextBox1.Text))
            {
                ICoreService service = Global.Get<ICoreService>();
                User user = service.FindUser(TextBox1.Text.Trim());
                if(user!=null)
                {
                    FormsAuthentication.SetAuthCookie(user.Account, false);
                    Response.Redirect("Shell.aspx");
                }
            }
        }
    }
}